package WH;

import com.microsoft.schemas._2003._10.serialization.arrays.ArrayOfstring;
import org.datacontract.schemas._2004._07.warehouseservice.ArrayOfParts;
import org.tempuri.IWarehouseService;
import org.tempuri.Warehouse;

/**
 *
 * @author Kristoffer Vangsnes Pedersen
 */
public class WarehouseClient {

    Warehouse service = new Warehouse();
    IWarehouseService port = service.getBasicHttpBindingIWarehouseService();
    
    
    public void printWarehouse(){
    
        ArrayOfParts array = port.getParts();
        
        for(int i = 0; i < array.getParts().size(); i++){

            System.out.println(array.getParts().get(i).getId());
            System.out.println(array.getParts().get(i).getName().getValue());
            System.out.println(array.getParts().get(i).getOrdertime());
            System.out.println(array.getParts().get(i).getPrice());
            System.out.println(array.getParts().get(i).getQuantity());        
            
        }
    }
    
    public void testCheckStock(String partName){
    
        System.out.println(port.checkStockPart(partName));
    }
    
    public void testSetQuantity(String name, int quantity){
    
        System.out.println("Setting part: " + name + " to quantity: " + quantity);
        port.setQuantityPart(name, quantity);
        System.out.println("Stock has changed! Value is now: " + port.checkStockPart(name));
    }
    
    public void testCalcOrder(ArrayOfstring parts){
    
        int orderCost = 0;
        
        orderCost = port.calculateOrderPrice(parts);
        
        System.out.println(orderCost);
    }
}
